package com.deli.jpa.entity.Controller;

import com.deli.jpa.entity.User;
import com.deli.jpa.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @Author: xudeli
 * @CreateDate: 2018/9/17 15:08
 **/
@RestController
public class UserController {
    @Autowired
    UserRepository userRepository;

    @GetMapping("/user/{id}")
    public User getUserById(@PathVariable("id") Integer id) {
        User user = userRepository.getOne(id);
        return user;
    }

    @GetMapping("/user")
    public User insertUser(@RequestParam("id") Integer id) {
        User user1 = userRepository.getUserById(id);
        return user1;
    }
}
